﻿using System;
using System.Data;
using System.Text;
using System.Data.OracleClient;
using DBUtility;
using System.Collections;//请先添加引用
namespace DBEmr.DAL
{
	/// <summary>
	/// 数据访问类NATION。
	/// </summary>
	public class NATION
	{
        DbHelperOra sql_help;
		public NATION()
		{
			sql_help = new DbHelperOra();
		}
		#region  成员方法


		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(string ID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from NATION");
			strSql.Append(" where ID='"+ID+"' ");
			return sql_help.Exists(strSql.ToString());
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public void Add(DBEmr.Model.NATION model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into NATION(");
			strSql.Append("ID,NAME,PYM");
			strSql.Append(")");
			strSql.Append(" values (");
			strSql.Append("'"+model.ID+"',");
			strSql.Append("'"+model.NAME+"',");
			strSql.Append("'"+model.PYM+"'");
			strSql.Append(")");
			sql_help.ExecuteSql(strSql.ToString());
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public void Update(DBEmr.Model.NATION model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update NATION set ");
			strSql.Append("NAME='"+model.NAME+"',");
			strSql.Append("PYM='"+model.PYM+"'");
			strSql.Append(" where ID='"+ model.ID+"' ");
			sql_help.ExecuteSql(strSql.ToString());
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public void Delete(string ID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete NATION ");
			strSql.Append(" where ID='"+ID+"' " );
			sql_help.ExecuteSql(strSql.ToString());
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public DBEmr.Model.NATION GetModel(string ID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ID,NAME,PYM ");
			strSql.Append(" from NATION ");
			strSql.Append(" where ID='"+ID+"' " );
			DBEmr.Model.NATION model=new DBEmr.Model.NATION();
			DataSet ds=sql_help.Query(strSql.ToString());
			if(ds.Tables[0].Rows.Count>0)
			{
				model.ID=ds.Tables[0].Rows[0]["ID"].ToString();
				model.NAME=ds.Tables[0].Rows[0]["NAME"].ToString();
				model.PYM=ds.Tables[0].Rows[0]["PYM"].ToString();
				return model;
			}
			else
			{
				return null;
			}
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ID,NAME,PYM ");
			strSql.Append(" FROM NATION ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return sql_help.Query(strSql.ToString());
		}


        /// <summary>
        /// 获得数据List列表
        /// </summary>
        public ArrayList GetModelList()
        {
            DBEmr.Model.NATION model;
            ArrayList List_model = new ArrayList();
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ID,NAME,PYM ");
            strSql.Append(" FROM NATION ");
            DataSet ds = sql_help.Query(strSql.ToString());
            if (ds.Tables[0].Rows.Count > 0)
            {
                model = new DBEmr.Model.NATION();
                model.ID = ds.Tables[0].Rows[0]["ID"].ToString();
                model.NAME = ds.Tables[0].Rows[0]["NAME"].ToString();
                model.PYM = ds.Tables[0].Rows[0]["PYM"].ToString();
                List_model.Add(model);

            }
            else
            {
                return null;
            }
            return List_model;
        }

		/*
		*/

		#endregion  成员方法
	}
}

